﻿using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

namespace EntitySetBase
{
    public abstract class EntitySetWithCreate : EntitySet, IEntitySetWithCreate
    {
        [Column("created_by"), Required, MaxLength(36)]
        public string CreatedBy { get; set; }
        [Column("created_on"), Required]
        public DateTime CreatedOn { get; set; }
        [Column("row_version"), Required, MaxLength(36), ConcurrencyCheck]
        public string RowVersion { get; set; }

        public void Create(string createdBy = null)
        {
            CreatedBy = createdBy;
            CreatedOn = DateTime.Now;
            RowVersion = Guid.NewGuid().ToString();
        }
    }
}
